package com.xyz.messagehelper.ui.activity

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Handler
import com.xyz.messagehelper.R
import com.xyz.messagehelper.contract.SplashContract
import com.xyz.messagehelper.presenter.SplashPresenter
import com.xyz.messagehelper.utils.ActivityConctroler
import org.jetbrains.anko.startActivity
import java.lang.ref.WeakReference

@SuppressLint("Registered")
class SplashActivity : BaseActivity(), SplashContract.View {

    val presenter = SplashPresenter(this)

    val handler by lazy {
        Handler()
    }

    //在这个页面的停留时间
    val DELAY_TIME = 2000L

    override fun init() {
        super.init()
        ActivityConctroler.add(WeakReference(this))
        presenter.checkLoginStatus()
    }

    override fun onNotLoggedIn() {

    }

    override fun onLoggedIn() {
        handler.postDelayed({
            startActivity<HomeActivity>()
            finish()
        }, DELAY_TIME)
    }

    override fun getLayoudResId(): Int = R.layout.activity_splash


}
